import { IPromiseUtils } from '../interface/IPromiseUtils';

/**
 * @class PromiseUtils
 * @description Promise 相关
 * @implements IPromiseUtils
 */
class PromiseUtils implements IPromiseUtils {
  constructor() {}

  public isPromiseLike(value: any) {
    return (
      value !== null &&
      (typeof value === 'object' || typeof value === 'function') &&
      (typeof value.then === 'function' || typeof value.catch === 'function')
    );
  }
}

const promiseUtils = new PromiseUtils();
export default promiseUtils;
